package com.usian.wemedia.service.impl;

import com.alibaba.nacos.client.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import com.usian.model.media.pojos.WmUser;
import com.usian.wemedia.mapper.WemediaUserMapper;
import com.usian.wemedia.service.WemediaUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WemediaUserServiceImpl extends ServiceImpl<WemediaUserMapper, WmUser> implements WemediaUserService {
    @Autowired
    private WemediaUserService wemediaUserService;

    /**
     * 添加自媒体用户
     *
     * @param wmUser
     * @return
     */
    @Override
    public ResponseResult add(WmUser wmUser) {
        wemediaUserService.save(wmUser);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }

    /**
     * 按照用户名字查询
     *
     * @param name
     * @return
     */
    @Override
    public List<WmUser> findByName(String name) {
        if (StringUtils.isNotBlank(name)) {
            LambdaQueryWrapper<WmUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(WmUser::getName, name);
            return list(lambdaQueryWrapper);
        }
        return null;
    }

}
